---
title: MessageFormatting
summary: API reference for MessageFormatting.
status: draft
owner: SAIF Documentation
last_reviewed: 2026-08-21
library: SAIF.Application
reference_type: embedded
---

# MessageFormatting

`MessageFormatting` is a static (`Public Shared`) helper class used by managers and consumers to render an already-accumulated set of message strings into a single, de-duplicated, separator-joined block of text for a specific display channel — web (`<BR>`), console/Windows (`vbCrLf`), or a caller-defined separator. It complements `AppManagerBase.AppendMessageLines`, which builds the single `Message` string incrementally, by supporting a batch-rendering path over an array of messages ([BR-APP-005](../../business-rules.md#br-app-005-duplicate-message-text-is-never-shown-twice), [BR-APP-010](../../business-rules.md#br-app-010-messages-render-with-a-channel-appropriate-defaulted-separator)).

## Purpose
- De-duplicates and joins message arrays for two default channels (web, console) plus an arbitrary caller-supplied separator ([BR-APP-010](../../business-rules.md#br-app-010-messages-render-with-a-channel-appropriate-defaulted-separator)).
- Strips pre-existing `vbCrLf` / `<BR>` markers from message text before re-joining, so channel switching does not double up separators.
- Supports appending a freshly joined message list onto an existing message buffer, inserting a separator seam only when that buffer is already non-blank.

## Context
- Namespace: `SAIF.Application`
- Assembly/package: `SAIF.Application` (embedded, ProjectReference)

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| `GetMessagesForWindows` | `Public Shared Function (inMessages As String()) As String` | De-duplicates and joins messages with `vbCrLf` for console/Windows display. |
| `GetMessagesForWeb` | `Public Shared Function (inMessages As String()) As String` | De-duplicates and joins messages with `<BR>` for browser display ([BR-APP-010](../../business-rules.md#br-app-010-messages-render-with-a-channel-appropriate-defaulted-separator)). |
| `GetMessagesUserDefined` | `Public Shared Function (inMessages As String(), inConcatString As String) As String` | De-duplicates and joins messages with a caller-supplied separator. |
| `BuildMessageString` | `Public Shared Function (inMessages As List(Of String), inConcatString As String) As String` | Joins an already-prepared list, omitting the separator after the last element. |
| `AppendMessageString` | `Public Shared Sub (ByRef inMessage As String, inMessages As List(Of String), inConcatString As String)` | Appends a joined list onto an existing message buffer, inserting a literal `<br>` seam first when the buffer is non-blank. |

## Behavioral notes
- `RemoveReturns` (`Private Shared`) strips existing `vbCrLf` or `<BR>` markers before re-joining; it is internal and not part of the public surface.
- `AppendMessageString` ignores the caller's own separator for the buffer seam and always inserts a literal `<br>`, which differs from the separator used for the rest of the joined list.*
- Every `GetMessages*` variant drops duplicate message text via an `If Not Results.Contains(temp)` guard, matching `AppManagerBase`'s own de-duplication behavior ([BR-APP-005](../../business-rules.md#br-app-005-duplicate-message-text-is-never-shown-twice)).

## Constraints and usage notes
- Console/Windows callers must explicitly select `GetMessagesForWindows` (or reset `AppManagerBase.NewLineCharacter`); the library-wide default separator is HTML-oriented (`<BR>`).

> **Note:** Statements marked with `*` were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with `**` could not be confirmed; treat as unknown until verified.

## Sources
- `SAIF.Application/MessageFormatting.vb`
- `SAIF.Application/AppManagerBase.vb`
